package cn.tedu.boot.ers.controller;

import cn.tedu.boot.ers.pojo.dto.ProductListDTO;
import cn.tedu.boot.ers.pojo.vo.ProductVO;
import cn.tedu.boot.ers.service.ProductService;
import cn.tedu.boot.ers.web.JsonResult;
import com.github.pagehelper.PageInfo;
import com.github.xiaoymin.knife4j.annotations.ApiOperationSupport;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiModelProperty;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * @Description: 前台商品controller
 * @Author: han
 * @Date:
 **/

@RestController
@Api(tags = "商品管理模块")
public class ProductController {
    @Autowired
    ProductService productService;

    @ApiOperation("商品详情")
    @ApiOperationSupport(order = 106)
    @GetMapping("product/detail")
    public JsonResult detail(@RequestParam Long id) {
        ProductVO product = productService.detail(id);
        return JsonResult.ok(product);
    }

    @ApiOperation("前台商品列表")
    @ApiOperationSupport(order = 107)
    @GetMapping("product/list")
    public JsonResult list(ProductListDTO productListDTO) {
        PageInfo list = productService.list(productListDTO);
        return JsonResult.ok(list);
    }


}
